<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
	<title>湖南省自来水公司营销管理信息系统</title> 
	
	<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/grid.css" type="text/css" media="screen" title="no title" />	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" title="no title" />	
	
	<link rel="stylesheet" href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />
	
	<link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen" title="no title">
	<script src="../js/jquery/jquery-3.3.1.js"></script>

</head> 
 
<body> 

<div id="wrapper">	
	
<div id="bool"><script>window.onload=function (){  $("#bool").load("../ming.html");}</script></div>


	<div id="content" class="xgrid">
		
 		
		<div class="x12">
			
			<h2>发票出库</h2>
			
			<div class="form label-inline uniform">
	
				<div class="field"><label for="OutDate">出库时间</label> <input id="OutDate" name="fname" size="50" type="text" class="medium" disabled="disabled" /></div>

				<div class="field"><label for="OutEmpID">出库人</label> <input  id="empname" name="lname" size="50" type="text" class="medium" disabled="disabled" /></div>
				<input  id="OutEmpID"  type="hidden" disabled="disabled" v-model="IvOutinvoice.OutEmpID" >
				
				<div class="field"><label for="EmpID">领用人</label>
                    <select class="medium" id="EmpID" name="EmpID" v-model="IvOutinvoice.EmpID">
						<option value="1">张三23</option>
						<option value="2">李四</option>
						<option value="3">23676</option>
						<option value="4">65</option>
						<option value="5">李五</option>
						<option value="6">小明</option>
						<option value="7">23234</option>
						<option value="8">123</option>
                        <option value="9">1231</option>
                        <option value="10">1111</option>
                        <option value="11">wer</option>
                        <option value="12">张宝</option>
                        <option value="13">李峰</option>
					</select></div>
					
				<div class="field"><label for="InvoiceType">发票类型</label> <input id="InvoiceType" v-model="vv.InvoiceType" name="lname" size="50" type="text" class="medium" disabled="disabled" placeholder="填入发票号码后，Ajax查询" />
                        <input type="hidden" v-model="IvOutinvoice.InID" id="InID" />
                </div>
				
				<div class="field"><label for="StartNo">发票起始号码</label> <input id="StartNo" @change="queryStarNo()" v-model="IvOutinvoice.StartNo" name="lname" size="50" type="text" class="medium" /></div>
				
				<div class="field"><label for="EndNo">发票终止号码</label> <input id="EndNo" onchange="fp()" v-model="IvOutinvoice.EndNo" name="lname" size="50" type="text" class="medium" @change="fptype()" /></div>
				
				<div class="field"><label for="OutCounts">发票张数</label> <input id="OutCounts" name="lname" v-model="IvOutinvoice.OutCounts" size="50" type="text" class="medium" disabled="disabled" placeholder="填入发票号码后，动态显示" /></div>

                <script>
                    function fp() {
                        var StartNo=$("#StartNo").val();
                        var EndNo=$("#EndNo").val();
                        var kool=EndNo-StartNo+1;
                        if(kool<=1){
                            swal(
                                '终止号码必须大于初始号码!',
                                'warning!',
                                'warning'
                            )
                            kool=null;
                        }
                        $("#OutCounts").val(kool);
                        content.IvOutinvoice.OutCounts=kool;
                    }
                </script>

				<div class="buttonrow">
					<button class="btn" @click="add()" >保存</button>
					<button class="btn btn-grey" onClick="history.back(-1);">返回</button>
				</div>

			</div>
			
		</div> <!-- .x12 -->
		
	</div> <!-- #content -->
	

	
</div> <!-- #wrapper -->

<script src="../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../js/misc/excanvas.min.js"></script>
<script src="../js/jquery/facebox.js"></script>
<script src="../js/jquery/jquery.visualize.js"></script>
<script src="../js/jquery/jquery.dataTables.min.js"></script>
<script src="../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../js/jquery/jquery.uniform.min.js"></script>
<script src="../js/jquery/jquery.placeholder.min.js"></script>

<script src="../js/widgets.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/vue.js"></script>

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script>
    function tools() {
        var date= new Date();
        var time =date.getFullYear()+"-"+(date.getMonth()+1)+"-"+(date.getDay()+13)+"  "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()
        $("#OutDate").val(time)
    }
    window.onload=function(){
        window.setInterval(tools,500);

    }
</script>

<script>

    function ff() {
        $.post("/getOutID",{},function (str) {
             //alert(str)
        })
    }

    var content=new Vue({
        el:"#wrapper",
        data:{
            ivs:'', //IvOutinvoice集合
            IvOutinvoice:{
                EmpID:'',
                InID:'',
                StartNo:'',
                EndNo:'',
                OutCounts:'',
                OutEmpID:'1'
            },
            iv:'',
            vv:{
                InvoiceType:''
            }
        },
        methods:{
            add(){
                //alert(JSON.stringify(this.IvOutinvoice));
                $.post("/iv-outadd",this.IvOutinvoice,function (str) {
                    //alert(str)
                    if(str!=0){
                        swal(
                            '出库成功!',
                            'success!',
                            'success'
                        )
                        ff();
                        setTimeout("javascript:location.href='inv_invoiceManage.html'", 1000);
                    }else{
                        swal(
                            '出库失败!',
                            'success!',
                            'success'
                        )
                    }
                })
            },
            fptype(){
                $.post("/FPCK_FPLX",this.IvOutinvoice,function (str) {
                    var arr = str.split(",");
                    //alert(arr[0]);
                    //alert(arr[1]);
                    if(str=="普通发票"){
                        $("#InvoiceType").val();
                        content.vv.InvoiceType=arr[0];
                    }else{
                        $("#InvoiceType").val();
                        content.vv.InvoiceType=arr[0];
                        content.IvOutinvoice.InID=arr[1];
                    }

                });
            },
            queryStarNo(){
                var StartNo=$("#StartNo").val();
                $.post("/iv-out-StartNo",{"StartNo":StartNo},function (str) {
                    //alert(str)
                    if(str==1){
                        swal(
                            '发票可出库!',
                            'success!',
                            'success'
                        )
                    }else{
                        swal(
                            '发票已出库!',
                            'error!',
                            'error'
                        )
                    }
                })
            },

        },
        created() {
			$(function(){
				$("#bool").load("../ming.html");
				setTimeout(function(){
					//alert(JSON.stringify(ming.Syemp))
					$("#empname").val(ming.Syemp.empNmae)
					$("#OutEmpID").val(ming.Syemp.id)
				},100)
			})
        },


    });

</script>

<!--<script type="text/javascript">-->
	<!---->
<!--$(document).ready ( function () -->
<!--{-->
	<!--Dashboard.init ();		-->
<!--});-->

<!--</script>-->

</body> 
 
</html>